/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package se.bth.ke.firstfriend.dto.todo.helper;

import java.util.Comparator;
import se.bth.ke.firstfriend.model.dto.TodoInfo;

/**
 *
 * @author nico
 */
public class RelevanceComparator implements Comparator<TodoInfo> {

    @Override
    public int compare(TodoInfo t1, TodoInfo t2) {
        return getRelevance(t1).compareTo(getRelevance(t2));
    }
    
    private Double getRelevance(TodoInfo info) {
        return (info.getArticle().getRelevance() + 1) *
               (0.333 * (info.getTodo().getPriority() + 1));
    }
}
